{% extends "base.html" %}
{% block header %}

{% endblock %}

{% block h_message %}
  {%if postback%}
    <div class="info {%if not result%}error{%endif%}">{{msg}}</div>
  {%endif%}
{% endblock %}
{% block nav2 %}
<a href="/admin/post" {%ifequal entrytype 'post'%} class="current" {%endifequal%}>New Post</a>  <a href="/admin/page" {%ifequal entrytype 'page'%} class="current" {%endifequal%}>New Page</a>
{% endblock %}

 {% block content %}
 <!-- tinyMCE -->
<script language="javascript" type="text/javascript"
src="/static/js/tiny_mce/tiny_mce.js"></script>
<script language="javascript" type="text/javascript">
	tinyMCE.init({
        language : 'zh',
		mode : "textareas",
        theme : "advanced",
        dialog_type : "modal",
		plugins : "fullscreen,preview",
        theme_advanced_buttons1 :   "bold,italic,underline,separator,strikethrough,justifyleft,justifycenter,justifyright,justifyfull,bullist,numlist,formatselect,forecolor,backcolor,undo,redo,link,unlink,separator,image,code,separator,fullscreen,preview",
        theme_advanced_buttons2 : "",
        theme_advanced_buttons3 : "",
        theme_advanced_toolbar_location : "top",
        theme_advanced_toolbar_align : "left",
        theme_advanced_statusbar_location : "bottom",
        theme_advanced_resizing : true,
        theme_advanced_resize_horizontal : false

	});

	function toggleEditor(id,status) {
        if (status)
        {
         tinyMCE.execCommand('mceAddControl', false, id);
         $('#spn_visual').addClass('tg');
         $('#spn_html').removeClass('tg');

        }
        else
        {
         tinyMCE.execCommand('mceRemoveControl', false, id);
         $('#spn_html').addClass('tg');
         $('#spn_visual').removeClass('tg');
        }
    }

</script>
<!-- /tinyMCE -->

<form action="/admin/{{entrytype}}" method="post">

   <div class="wrap">

      <h2>Write {{entrytype}}</h2>
      <div id="poststuff">

<div id="submitlink" class="submitbox">

<div id="previewview">
</div>
{%ifequal entry.entrytype "post"%}
<h3>Category</h3>
<div class="inside">

<p style="height:120px;overflow-y:scroll">
                    {%for cat in cats%}

                       <input type="checkbox" name="cats"  value="{{cat.slug}}" {%if cat.select %}checked="checked"{%endif%}/>{{cat.name}}<br>
                    {%endfor%}
                    </select>
</p>

</div>
{%endifequal%}
<p class="submit">
<input type="submit" tabindex="4" value="Save" name="save" class="button button-highlighted"/>
  <input type="checkbox" style="margin-left:10px;" tabindex="4" value="publish" name="publish" class="button button-highlighted" {%if entry.published%}checked="checked"{%endif%}/>Published
</p>

<div class="side-info">
<h5>Related</h5>

<ul>
<li><a href="/admin/entries/post">Manage All Posts</a></li>
<li><a href="/admin/entries/page">Manage All Pages</a></li>

</ul>
</div>
</div>

<div id="post-body2">
<div id="titlediv">
<h3>Title</h3>
<div id="titlewrap">
	<input type="text" autocomplete="off" id="title" value="{{entry.title}}" tabindex="1" size="60" name="post_title"/>
</div>
<div class="inside">
	<div id="edit-slug-box">
	</div>
</div>
</div>

<div class="stuffbox" id="postarea">
<h3>{{entrytype}}</h3>
<div class='editor-toolbar'>
    <span class="alignright" id="spn_html"><a href="javascript:toggleEditor('t_content',false);">HTML</a></span>
    <span class="alignright tg"  id="spn_visual"><a href="javascript:toggleEditor('t_content',true);">Visual</a></span>
    <div class='clear'></div>
</div>
<div id="editorcontainer">
<textarea  style='width:100%;height:200px' cols="40" rows="10" id="t_content" name="content">{{entry.content}}</textarea>
</div>
</div>

<div class="clear"></div>
<div class="stuffbox" id="tag">
<h3>Slug</h3>
<div class="inside">
	<input type="text" id="tags" value="{{entry.slug}}" tabindex="1" size="30" name="slug"/><br/>
</div>
</div>
{%ifequal entry.entrytype "post"%}
<div class="clear"></div>
<div class="stuffbox" id="tag">
<h3>Tag</h3>
<div class="inside">
	<input type="text" id="tags" value="{{entry.strtags}}" tabindex="1" size="30" name="tags"/><br/>
</div>
</div>

{%else%}
<div class="clear"></div>
<div class="stuffbox" >
<h3>Options</h3>
<div class="inside">
  	<p>
     <span style="font-weight:bold;width:30px"> Page level: </span><input type="text" id="entry_parent" value="{{entry.entry_parent}}" tabindex="1" size="4" name="entry_parent"/>
  	<p>
      <span  style="font-weight:bold;width:30px">Page order:</span> <input type="text" id="menu_order" value="{{entry.menu_order}}" tabindex="1" size="4" name="menu_order"/>

    </p>
</div>
</div>


{%endifequal%}




<input type="hidden" value="{{entry.key}}" name="key"/>
<input type="hidden" value="{{action}}" name="action"/>

</div>
</div>

   </div>
   </form>

 {% endblock  %}